/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Reynusa
 */
public class Barang {
    private String KodeBarang;
    private String NamaBarang;
    private String JenisBarang;
    private int JumlahBarang;
    private double HargaBarang;
    private String KodeToko;

    public String getKodeToko() {
        return KodeToko;
    }

    public void setKodeToko(String KodeToko) {
        this.KodeToko = KodeToko;
    }

    public Barang() {
    }

    public double getHargaBarang() {
        return HargaBarang;
    }

    public void setHargaBarang(double HargaBarang) {
        this.HargaBarang = HargaBarang;
    }

    public String getJenisBarang() {
        return JenisBarang;
    }

    public void setJenisBarang(String JenisBarang) {
        this.JenisBarang = JenisBarang;
    }

    public int getJumlahBarang() {
        return JumlahBarang;
    }

    public void setJumlahBarang(int JumlahBarang) {
        this.JumlahBarang = JumlahBarang;
    }

    public String getKodeBarang() {
        return KodeBarang;
    }

    public void setKodeBarang(String KodeBarang) {
        this.KodeBarang = KodeBarang;
    }

    public String getNamaBarang() {
        return NamaBarang;
    }

    public void setNamaBarang(String NamaBarang) {
        this.NamaBarang = NamaBarang;
    }

    public List tampilstok() throws SQLException {
        List stok1 = new ArrayList();
        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs125314075", "mhs125314075");
//        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@localhost:1521:xe", "reynusa", "reynusa");
        Statement st = conn.createStatement();
            String stokck = "select * from stok";
            ResultSet rs = st.executeQuery(stokck);
            while (rs.next()) {
                Barang stokx = new Barang();
                stokx.setKodeBarang(rs.getString("KodeBarang"));
                stokx.setNamaBarang(rs.getString("NamaBarang"));
                stokx.setJenisBarang(rs.getString("JenisBarang"));
                stokx.setHargaBarang(rs.getDouble("HargaBarang"));
                stokx.setJumlahBarang(rs.getInt("JumlahBarang"));
                stok1.add(stokx);
            }
     
        conn.commit();
        return stok1;
    }
    public List tampilstoka() throws SQLException {
        List stok1 = new ArrayList();
        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs125314075", "mhs125314075");
//        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@localhost:1521:xe", "reynusa", "reynusa");
        Statement st = conn.createStatement();
            String stokck = "select * from stoka";
            ResultSet rs = st.executeQuery(stokck);
            while (rs.next()) {
                Barang stokx = new Barang();
                stokx.setKodeBarang(rs.getString("KodeBarang"));
                stokx.setNamaBarang(rs.getString("NamaBarang"));
                stokx.setJenisBarang(rs.getString("JenisBarang"));
                stokx.setHargaBarang(rs.getDouble("HargaBarang"));
                stokx.setJumlahBarang(rs.getInt("JumlahBarang"));
                stok1.add(stokx);
            }
     
        conn.commit();
        return stok1;
    }
    public List tampilstokb() throws SQLException {
        List stok1 = new ArrayList();
        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs125314075", "mhs125314075");
//        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@localhost:1521:xe", "reynusa", "reynusa");
        Statement st = conn.createStatement();
            String stokck = "select * from stokb";
            ResultSet rs = st.executeQuery(stokck);
            while (rs.next()) {
                Barang stokx = new Barang();
                stokx.setKodeBarang(rs.getString("KodeBarang"));
                stokx.setNamaBarang(rs.getString("NamaBarang"));
                stokx.setJenisBarang(rs.getString("JenisBarang"));
                stokx.setHargaBarang(rs.getDouble("HargaBarang"));
                stokx.setJumlahBarang(rs.getInt("JumlahBarang"));
                stok1.add(stokx);
            }
     
        conn.commit();
        return stok1;
    }
    public List tampilstokc() throws SQLException {
        List stok1 = new ArrayList();
        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs125314075", "mhs125314075");
//        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@localhost:1521:xe", "reynusa", "reynusa");
        Statement st = conn.createStatement();
            String stokck = "select * from stokc";
            ResultSet rs = st.executeQuery(stokck);
            while (rs.next()) {
                Barang stokx = new Barang();
                stokx.setKodeBarang(rs.getString("KodeBarang"));
                stokx.setNamaBarang(rs.getString("NamaBarang"));
                stokx.setJenisBarang(rs.getString("JenisBarang"));
                stokx.setHargaBarang(rs.getDouble("HargaBarang"));
                stokx.setJumlahBarang(rs.getInt("JumlahBarang"));
                stok1.add(stokx);
            }
     
        conn.commit();
        return stok1;
    }
}